package net.xdclass.onlinexdclass.utils;


/**
 * 解决协议未统一，缺少前端状态码，增加状态码等，方便前端判断
 */
public class JsonDate {


    private Integer code;

    private Object data;

    private String msg;


    public JsonDate() {

    }

    public JsonDate(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public JsonDate(Integer code, Object data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }


    public static JsonDate bulidSuccess(Object data) {
        return new JsonDate(0, data);
    }

    public static JsonDate bulidSuccess() {
        return new JsonDate(0, "成功");
    }

    public static JsonDate bulidError(String msg) {
        return new JsonDate(-1, "", msg);
    }

    public static JsonDate bulidError(String msg, int code) {
        return new JsonDate(code, msg);
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getdata() {
        return data;
    }

    public void setdata(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "JsonDate{" +
                "code=" + code +
                ", data=" + data +
                ", msg='" + msg + '\'' +
                '}';
    }
}
